import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDEAction } from '../action/ipsdeaction';
import { IPSDEMap } from './ipsdemap';
import { IPSDEMapAction } from './ipsdemap-action';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEMapActionImpl extends PSModelObjectImpl implements IPSDEMapAction {
  get codeName(): string {
    return this.M.codeName;
  }

  protected dstpsdeaction: IPSDEAction | null = null;

  getDstPSDEAction(): IPSDEAction | null {
    if (this.dstpsdeaction != null) return this.dstpsdeaction;
    const value = this.M.getDstPSDEAction;
    if (value == null) {
      return null;
    }
    const ipsdemap = this.getParentPSModelObject('dataentity.datamap.IPSDEMap') as IPSDEMap;
    if (ipsdemap != null) {
      this.dstpsdeaction = ipsdemap.getDstPSDEMust().findPSDEAction(value);
    }
    return this.dstpsdeaction;
  }

  get dstPSDEAction(): IPSDEAction | null {
    return this.getDstPSDEAction();
  }

  getDstPSDEActionMust(): IPSDEAction {
    const value = this.getDstPSDEAction();
    if (value == null) {
      throw new Error('未指定目标实体行为');
    }
    return value;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get mapMode(): 'DEFAULT' | 'INNER' {
    return this.M.mapMode || 'DEFAULT';
  }

  get mapParams(): IModel {
    return this.M.mapParams;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected srcpsdeaction: IPSDEAction | null = null;

  getSrcPSDEAction(): IPSDEAction | null {
    if (this.srcpsdeaction != null) return this.srcpsdeaction;
    const value = this.M.getSrcPSDEAction;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.srcpsdeaction = ipsdataentity.findPSDEAction(value);
    }
    return this.srcpsdeaction;
  }

  get srcPSDEAction(): IPSDEAction | null {
    return this.getSrcPSDEAction();
  }

  getSrcPSDEActionMust(): IPSDEAction {
    const value = this.getSrcPSDEAction();
    if (value == null) {
      throw new Error('未指定源实体行为');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSDEMapActionImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.datamap.IPSDEMapAction') return true;
    return super.instanceof(cls);
  }
}
